/*
 * 根据id删除数据
 */
function delById(prefix,id){
	
	if(!window.confirm("确认删除？")){
		return ;
	}

	var url=prefix+"/product/delete";
	$.post(url,{"id":id},function(data){
		alert("删除成功");
		location.reload(true);
	},'json');
}
function dependById(prefix,id)
{
	
	if(!window.confirm("确认配货？")){
		return ;
	}

	var url=prefix+"/supplierProduct/depend";
	$.post(url,{"id":id},function(data){
		alert("设置配货成功");
		location.reload(true);
	},'json');
}
//配货
function dependByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		alert("请选择要配货的订单");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认配货？")){
		return;
	}
	var url=prefix+"/supplierProduct/dependOrder";
	$.post(url,{"idStr":str,},function(data){
		alert("设置配货成功");
		location.reload(true);
	},'json');
}
function endById(prefix,id){
	if(!window.confirm("确认订单完成？")){
		return ;
	}

	var url=prefix+"/supplierProduct/finish";
	$.post(url,{"id":id},function(data){
		alert("订单完成");
		location.reload(true);
	},'json');
}
function sendById(prefix,id)
{
	
	if(!window.confirm("确认发货？")){
		return ;
	}

	var url=prefix+"/supplierProduct/send";
	$.post(url,{"id":id},function(data){
		alert("设置发货成功");
		location.reload(true);
	},'json');
}
//发货
function sendByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		alert("请选择要发货的订单");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认发货？")){
		return;
	}
	var url=prefix+"/supplierProduct/sendOrder";
	$.post(url,{"idStr":str,},function(data){
		alert("设置发货成功");
		location.reload(true);
	},'json');
}
function turnById(prefix,id)
{
	
	if(!window.confirm("确认服务站收货？")){
		return ;
	}

	var url=prefix+"/companyAdmin/turnOne";
	$.post(url,{"id":id},function(data){
		alert("服务站收货成功");
		location.reload(true);
	},'json');
}
//服务站收货
function turnByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		alert("请选择服务站收货订单");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认服务站收货？")){
		return;
	}
	var url=prefix+"/companyAdmin/turnOrder";
	$.post(url,{"idStr":str,},function(data){
		alert("服务站收货成功");
		location.reload(true);
	},'json');
}
function serverById(prefix,id)
{
	
	if(!window.confirm("确认已提供服务？")){
		return ;
	}

	var url=prefix+"/companyAdmin/serverOne";
	$.post(url,{"id":id},function(data){
		alert("服务已完成");
		location.reload(true);
	},'json');
}

//服务站收货
function serverByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		alert("请选择完成的服务");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认已提供服务？")){
		return;
	}
	var url=prefix+"/companyAdmin/turnServer";
	$.post(url,{"idStr":str,},function(data){
		alert("服务已完成");
		location.reload(true);
	},'json');
}

function getById(prefix,id)
{
	
	if(!window.confirm("确认会员收货？")){
		return ;
	}

	var url=prefix+"/companyAdmin/getOne";
	$.post(url,{"id":id},function(data){
		alert("会员收货成功");
		location.reload(true);
	},'json');
}
//收货
function getByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		alert("请选择会员收货订单");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认会员收货？")){
		return;
	}
	var url=prefix+"/companyAdmin/getOrder";
	$.post(url,{"idStr":str,},function(data){
		alert("会员收货成功");
		location.reload(true);
	},'json');
}
//审核通过
function passById(prefix,id){
	if(!window.confirm("确认审核？")){
		return ;
	}
	
	var url=prefix+"/product/pass";
	$.post(url,{"id":id},function(data){
		alert("操作成功");
		location.reload(true);
	},'json');
}
/*
 * 根据多个id删除数据
 * @param {Object} prefix
 */
function delByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		alert("请选择要删除的商品");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认删除？")){
		return;
	}
	
	var url=prefix+"/product/deleteMany";
	$.post(url,{"idStr":str,},function(data){
		location.reload(true);
	},'json');
	
}

/*
 * 根据多个id审批通过数据
 * @param {Object} prefix
 */
function passByIds(prefix){
	
		var str="";
		var checkArray = document.getElementsByName("chk");
		for (var i = 0; i < checkArray.length; i++) {
			if(checkArray[i].checked){
				str += checkArray[i].value + ",";
			}
		}
		var dot = str.lastIndexOf(",");
		if(dot==-1){
			alert("请选择要审核的商品。");
			return;
		}else{
			str = str.substring(0,dot);
		}
		
		if(!window.confirm("确认审核通过？")){
			return;
		}
	
	var url=prefix+"/product/passMany";
	$.post(url,{"idStr":str},function(data){
		location.reload(true);
	},'json');
	
}